package com.qhg.saas_server.controller;

import com.github.pagehelper.PageInfo;
import com.qhg.saas_server.empty.Result;
import com.qhg.saas_server.pojo.dto.LogInfoDto;
import com.qhg.saas_server.service.impl.LogServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/Log")
public class LogController {

    @Autowired
    LogServiceImpl logService;

    /*通过操作人员和操作日期分页查询日志信息*/
    @PostMapping("/SelectAll")
    public Result SelectAll(Integer pageNum,Integer pageSize,String comploName, String logTime){
        if(logTime != null && logTime != ""){
            String newString = logTime.substring(0,11);
            logTime = newString;
        }
        PageInfo pageInfo = logService.SelectAll(pageNum, pageSize, comploName, logTime);
        return Result.success(pageInfo);
    }
    /*通过日期删除日志*/
    @GetMapping("/DeleteByTime")
    public Result DeleteByTime(String logTime){
        if(logTime != null && logTime != ""){
            String newString = logTime.substring(0,11);
            logTime = newString;
        }
        logService.DeleteByTime(logTime);
        return Result.buildSuccess();
    }
}
